<?php 
include 'method/win.php';

if(!isset($_SESSION['adminuser'])){
    show_msg("请先登录!","A-login.php");
}
if(isset($_GET['action'])){
    logout();
}
if(isset($_POST['submit'])){
    $_SESSION['shot'] = $_POST['search-str'];
}
if(isset($_SESSION['shot'])){
    $defsql = "select * from weibo_list where weibo_content like '%".$_SESSION['shot']."%' order by weibo_hot desc";
    $defres = $conn->query($defsql);
}else{
    $defsql = "select * from weibo_list order by weibo_hot desc";
    $defres = $conn->query($defsql);
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>热度调整</title>
    <link rel="stylesheet" href="css/A-public.css">
    <link rel="stylesheet" href="css/A-public.css">
    <link rel="stylesheet" href="../lib/bootstrap/css/bootstrap.css">
    <script src="../lib/jquery/jquery.js" type="text/javascript"></script>
</head>
<body style="background-color:#a1a3a6;">
<h3>热度调整</h3>
<div class="user">

    <span class="span1">当前登录管理员为：<span class="username"><?php echo $_SESSION['adminuser']?></span></span>

    <a class="float-right leave" href="A-index.php?action=logout">退出</a>
    <a class="leave" href="A-index.php">返回</a>
</div>
<div class="well">
    <form class="search" method="post" action="">
        <input type="text" name="search-str" class="input-top" placeholder="请输入搜索内容">
        <button type="submit" name="submit" class="submit glyphicon glyphicon-search"/>
    </form>
</div>

<div class="table-div1 table-responsive choose-1" id="div">
    <table class="table1 table-bordered">
        <tr class="">
            <td>序号</td>
            <td>id</td>
            <td>账号</td>
            <td>内容</td>
            <td>图片</td>
            <td>操作</td>
        </tr>
        <?php 
        $no = 1;
        if($defres->num_rows){
            while($rows = $defres->fetch_assoc()){
                echo "<tr class=''>";
                echo "<td width=5%>".$no."</td>";
                echo "<td width=5%>".$rows['weibo_id']."</td>";
                echo "<td width=10%>".$rows['author']."</td>";
                echo "<td>".$rows['weibo_content']."</td>";
                if($rows['weibo_img']){
                    echo "<td><img src='../".$rows['weibo_img']."' style='width: 167px ;height: 167px'></td>";
                }else{
                    echo "<td><div style='width: 167px; height: 167px'></div></td>";
                }
                echo "<td width=5%><input onchange=changeHot(value,".$rows['weibo_id'].") class='input2' type='text' value='".$rows['weibo_hot']."'></td>";
                echo "</tr>";
                $no = $no+1;
            }
        }else{
            echo "<tr class=''>暂无相关微博</tr>";
        }
        
        ?>
    </table>
</div>
</body>
<script>
function changeHot(change, id){
	$.ajax({
        type:"post",
		url:"method/changehot_action.php",
		data:{change: change,id: id},
		success:function(data){
				alert(data)
		}
    });
	location.reload();
}
</script>
</html>